package cn.qihua.service.impl;

import java.util.List;

import cn.qihua.dao.IBaseProductDAO;
import cn.qihua.model.BaseProduct;
import cn.qihua.service.IProductService;

public class ProductService implements IProductService {
	private IBaseProductDAO baseProductDAO;

	/*
	 * (non-Javadoc)
	 * 
	 * @see cn.qihua.service.impl.IBaseProductService#findAll()
	 */
	@Override
	@SuppressWarnings("unchecked")
	public List<BaseProduct> findAll() {
		return baseProductDAO.findAll();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see cn.qihua.service.impl.IBaseProductService#findAll(int, int)
	 */
	@Override
	@SuppressWarnings("unchecked")
	public List<BaseProduct> findAll(int start, int limit) {
		return baseProductDAO.findAll(start, limit);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see cn.qihua.service.impl.IBaseProductService#findByNow(int, int, int)
	 */
	@Override
	@SuppressWarnings("unchecked")
	public List<BaseProduct> findByNow(int after, int start, int limit) {
		return baseProductDAO.findByNow(after, start, limit);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * cn.qihua.service.impl.IBaseProductService#findByProperty(java.lang.String
	 * , java.lang.Object)
	 */
	@Override
	@SuppressWarnings("unchecked")
	public List<BaseProduct> findByProperty(String propertyName, Object value) {
		return baseProductDAO.findByProperty(propertyName, value);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * cn.qihua.service.impl.IBaseProductService#searchByProperty(java.lang.
	 * String, java.lang.String, int, int)
	 */
	@Override
	@SuppressWarnings("unchecked")
	public List<BaseProduct> searchByProperty(String propertyName,
			String value, int start, int limit) {
		return baseProductDAO.searchByProperty(propertyName, value, start,
				limit);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * cn.qihua.service.impl.IBaseProductService#searchByProperty(java.lang.
	 * String, java.lang.String)
	 */
	@Override
	@SuppressWarnings("unchecked")
	public List<BaseProduct> searchByProperty(String propertyName, String value) {
		return baseProductDAO.searchByProperty(propertyName, value);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * cn.qihua.service.impl.IBaseProductService#findByProperty(java.lang.String
	 * , java.lang.Object, int, int)
	 */
	@Override
	@SuppressWarnings("unchecked")
	public List<BaseProduct> findByProperty(String propertyName, Object value,
			int start, int limit) {
		return baseProductDAO.findByProperty(propertyName, value, start, limit);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see cn.qihua.service.impl.IBaseProductService#getTotal()
	 */
	@Override
	public Integer getTotal() {
		return baseProductDAO.getTotal();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * cn.qihua.service.impl.IBaseProductService#getTotalByWhere(java.lang.String
	 * )
	 */
	@Override
	public Integer getTotalByWhere(String where) {
		return baseProductDAO.getTotalByWhere(where);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * cn.qihua.service.impl.IBaseProductService#findByStatus(java.lang.String,
	 * int, int)
	 */
	@Override
	@SuppressWarnings("unchecked")
	public List<BaseProduct> findByStatus(String status, int start, int limit) {
		return baseProductDAO.findByStatus(status, start, limit);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * cn.qihua.service.impl.IBaseProductService#getTotalByProperty(java.lang
	 * .String, java.lang.Object)
	 */
	@Override
	public Integer getTotalByProperty(String propertyName, Object value) {
		return baseProductDAO.getTotalByProperty(propertyName, value);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * cn.qihua.service.impl.IBaseProductService#getTotalBySearch(java.lang.
	 * String, java.lang.String)
	 */
	@Override
	public Integer getTotalBySearch(String propertyName, String value) {
		return baseProductDAO.getTotalBySearch(propertyName, value);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see cn.qihua.service.impl.IBaseProductService#changeStatus(int, int)
	 */
	@Override
	public boolean changeStatus(int id, Boolean value) {
		return baseProductDAO.changeStatus(id, value);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see cn.qihua.service.impl.IBaseProductService#changePropertyById(int,
	 * java.lang.String, java.lang.Object)
	 */
	@Override
	public boolean changePropertyById(int id, String field, Object value) {
		return baseProductDAO.changePropertyById(id, field, value);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see cn.qihua.service.impl.IBaseProductService#changeProgress(int,
	 * java.lang.String)
	 */
	@Override
	public boolean changeProgress(int id, String value) {
		return baseProductDAO.changeProgress(id, value);

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see cn.qihua.service.impl.IBaseProductService#changeYears(int, int)
	 */
	@Override
	public boolean changeYears(int id, int value) {
		return baseProductDAO.changeYears(id, value);

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * cn.qihua.service.impl.IBaseProductService#findById(java.lang.Integer)
	 */
	@Override
	public BaseProduct findById(Integer id) {
		return baseProductDAO.findById(id);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * cn.qihua.service.impl.IBaseProductService#add(cn.qihua.model.BaseProduct)
	 */
	@Override
	public Boolean add(BaseProduct transientInstance) {
		return baseProductDAO.save(transientInstance);
	}

	@Override
	public Boolean update(BaseProduct transientInstance) {
		return baseProductDAO.update(transientInstance);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see cn.qihua.service.impl.IBaseProductService#add(int,
	 * cn.qihua.model.BaseProduct)
	 */
	@Override
	public Boolean add(int orderId, BaseProduct transientInstance) {
		transientInstance.setOrderId(orderId);
		return baseProductDAO.save(transientInstance);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see cn.qihua.service.impl.IBaseProductService#del(java.lang.Integer)
	 */
	@Override
	public boolean del(Integer id) {
		BaseProduct Pdt = baseProductDAO.findById(id);
		if (Pdt != null) {
			baseProductDAO.delete(Pdt);
			return true;
		} else {
			return false;
		}
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * cn.qihua.service.impl.IBaseProductService#edit(cn.qihua.model.BaseProduct
	 * )
	 */
	@Override
	public void edit(BaseProduct transientInstance) {
		baseProductDAO.update(transientInstance);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * cn.qihua.service.impl.IBaseProductService#setBaseProductDAO(cn.qihua.
	 * dao.IBaseProductDAO)
	 */
	@Override
	public void setBaseProductDAO(IBaseProductDAO baseProductDAO) {
		this.baseProductDAO = baseProductDAO;
	}

}
